<?php
require_once(FWK_EXCEPTION."CustonException.class.php");
require_once(BIB_ACTIVE_RECORD);
require_once(FWK_MODEL."AbsModelDao.class.php");
/**
 * @author Vinicius Rodrigues <viniciusmr3@gmail.com>
 * @since 1.0 - 23/12/2012
 */
class Endereco extends AbsModelDao{

	public $_table = "enderecos";

	public $_id = "id_endereco";

	public function getListaEnderecos(){
		$strQuery = "SELECT
							id_endereco, id_estado, logradouro_endereco, bairro_endereco,
							numero_endereco, cidade_endereco
							
					 FROM 
					 		".$this->_table;
		$arrRet = ControlDB::getAll($strQuery,3);
		return $arrRet;
	}
	
	public function alterar($id=null,$post){
		try{
			self::salvaPostAutoUtf8($post);
			$this->id_endereco = $id;
			
			self::replace();
			if(self::ErrorMsg()){
				print("<pre>");
				print_r($post);
				die("<br/><br /><h1>".self::ErrorMsg()."</h1>");
			}
		}catch(DaoException $e){
			throw new CustonException($e->getMensagem());
		}
	}
}
?>